package com.zt.controller;

import com.zt.service.CardBindingService;
import com.zt.system.CardBinding;
import com.zt.system.vo.CardTableVO;
import com.zt.utils.Result;
import com.zt.vo.CardBindingVo;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import cn.hutool.core.date.DateTime;
import com.zt.service.CardBindingService;
import com.zt.system.CardBinding;
import com.zt.utils.Result;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("cardBinding")
public class CardBindingController {

    @Resource
    private CardBindingService cardBindingService;

    //获取某个用户的银行卡列表
    @GetMapping("getCardBindingById")
    public Result getCardBindingById(Integer uid){
        return cardBindingService.getCardBindingById(uid);
    }


    //充值功能
    @GetMapping("Recharge")
    public Result Recharge(CardBindingVo cardBindingVo){
        return cardBindingService.Recharge(cardBindingVo);
    }

    //查询某张银行卡的卡号
    @GetMapping("getCardNumber")
    public String getCardNumber(Integer bindingId){
        return cardBindingService.getCardNumber(bindingId);
    }

    //查询某张银行卡的卡号
    @GetMapping("CardBindingByCardNumber")
    public CardBinding CardBindingByCardNumber(String cardNumber){
        return cardBindingService.CardBindingByCardNumber(cardNumber);
    }

    //提现
    @GetMapping("withdrawal")
    public Result withdrawal(CardBindingVo cardBindingVo){
        return cardBindingService.withdrawal(cardBindingVo);
    }
    //根据当前登录用户id获取该用户的主卡信息
    @GetMapping("cardBindingByUserId")
    public CardBinding cardBindingByUserId() {
        return cardBindingService.cardBindingByUserId();
    }

    //根据银行卡信息查询该银行卡信息
    @GetMapping("cardBindingByCardNumber")
    public CardBinding cardBindingByCardNumber(String cardNumber) {
        return cardBindingService.cardBindingByCardNumber(cardNumber);
    }

    //    根据银行卡id进行修改
    @PostMapping("cardBindingByBindingId")
    public Result cardBindingByBindingIdUpdate(CardTableVO cardTableVO) {
        return cardBindingService.cardBindingByBindingIdUpdate(cardTableVO);
    }
    //    还款根据银行卡id进行修改
    @PostMapping("cardBindingPayBackByBindingId")
    public Result cardBindingPayBackByBindingId(CardTableVO cardTableVO) {
        return cardBindingService.cardBindingPayBackByBindingId(cardTableVO);
    }
    //根据当前登录用户id获取该用户的所有信息
    @GetMapping("cardBindingFindByUserId")
    public List<CardBinding> cardBindingFindByUserId() {
        return cardBindingService.cardBindingFindByUserId();
    }

    //添加卡号
    @PostMapping("savebingcard")
    public Result savebingcard(@RequestBody CardBinding cardBinding)    {
        cardBinding.setBindingDate(new DateTime());
        boolean save = cardBindingService.savebingcard(cardBinding);
        return Result.success(save);
    }
    //修改卡的状态
    @PostMapping("updatebingcard")
    public Result updatebingcard(@RequestBody CardBinding cardBinding){
        Result result=cardBindingService.updatebangstatus(cardBinding);
        return result;
    }
//    @PostMapping("savebangcard")
//    public Result savebangcard(@RequestBody CardBinding cardBinding){
//        Result result=cardBindingService.savebangcard(cardBinding);
//        return result;
//    }
//点击生成验证码
@GetMapping("code")
public Result code(){
    return cardBindingService.code();
}



}
